<?php

class My_Controller extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->checkUserLogin();
        $data = array();
        $this->load->library('template');
        $this->template->set_template('default');
        
        // Add DocType
        $this->template->add_doctype();
        
        //$this->template->add_css('template/admin/css/screen.css');
        //$this->template->add_css('template/admin/css/datePicker.css');
        //$this->template->add_css('template/admin/css/redmond/jquery-ui-1.8.19.custom.css');
        $this->template->add_js('template/admin/js/jquery-1.7.2.min.js');
        $this->template->add_js('template/admin/js/jquery-ui-1.8.19.custom.min.js');
        
        //$this->template->add_js('template/admin/js/ui.core.js');
        //$this->template->add_js('template/admin/js/ui.checkbox.js');
        //$this->template->add_js('template/admin/js/jquery.bind.js');
        
        //$this->template->add_js('template/admin/js/app.js');
        
        
        //$this->template->add_js('template/admin/js/jquery.selectbox-0.5.js');
        //$this->template->add_js('template/admin/js/jquery.selectbox-0.5_style_2.js');
        //$this->template->add_js('template/admin/js/jquery.selectbox-0.5_style_3.js');
        //$this->template->add_js('template/admin/js/jquery.filestyle.js');
        //$this->template->add_js('template/admin/js/custom_jquery.js');
        //$this->template->add_js('template/admin/js/jquery.tooltip.js');
        //$this->template->add_js('template/admin/js/jquery.dimensions.js');
        //$this->template->add_js('template/admin/js/date.js');
        //$this->template->add_js('template/admin/js/jquery.datePicker.js');
        //$this->template->add_js('template/admin/js/jquery.pngFix.pack.js');
        
        // Parse data into view 
        //$this->template->parse_view('header','default/block/header',$data);
        //$this->template->parse_view('menu','default/block/menu',$data);
        //$this->template->parse_view('sidebarleft','default/sidebarleft/sidebarleft',$data);        
        //$this->template->parse_view('footer','default/block/footer',$data);
    }
    
    public function checkUserLogin(){
        $flag = false;
        if( $this->session->userdata('logged_in') == true || $this->session->userdata('logged_in') == 1 ){
            if( $this->session->userdata('user_role_id') == 1 || $this->session->userdata('user_role_id') == 2 ){
                $flag = true;
            }else{
                $flag = false;
            }
        }else{
            $flag = false;
        }
        
        if($flag == false){
            redirect('index/login');
        }
        return false;
    }
}